using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using LAMSDK.Security.Entities;

namespace LAMSDK.Security.Mapping
{
	public class RoleMap : EntityTypeConfiguration<Role>
	{
		public RoleMap()
		{
			// Primary Key
			this.HasKey(t => t.RoleId);

			// Properties
			this.Property(t => t.RoleName)
				.IsRequired()
				.HasMaxLength(255);
				
			this.Property(t => t.CreateDate)
				.IsFixedLength()
				.HasMaxLength(10);
				
			this.Property(t => t.CreateUser)
				.IsFixedLength()
				.HasMaxLength(10);
				
			this.Property(t => t.ChangeDate)
				.IsFixedLength()
				.HasMaxLength(10);
				
			this.Property(t => t.ChangeUser)
				.IsFixedLength()
				.HasMaxLength(10);
				
			// Table & Column Mappings
			this.ToTable("Role");
			this.Property(t => t.RoleId).HasColumnName("RoleId");
			this.Property(t => t.RoleName).HasColumnName("RoleName");
			this.Property(t => t.IsValided).HasColumnName("IsValided");
			this.Property(t => t.IsDeleted).HasColumnName("IsDeleted");
			this.Property(t => t.CreateDate).HasColumnName("CreateDate");
			this.Property(t => t.CreateUser).HasColumnName("CreateUser");
			this.Property(t => t.ChangeDate).HasColumnName("ChangeDate");
			this.Property(t => t.ChangeUser).HasColumnName("ChangeUser");
		}
	}
}

